package cn.jekun.shop.common.service;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import cn.jekun.component.base.exceptions.BusinessException;
import cn.jekun.component.core.Constants;
import cn.jekun.component.core.bean.gen.DCity;
@Service(SysParamService.BEAN_NAME)
public class SysParamService extends ShopBaseService {
	public static final String BEAN_NAME = "cn.jekun.shop.common.service.SysParamService";

	@SuppressWarnings({ "unchecked", "rawtypes" })
	public List finCityByProvince(@DCity.AnnoProvinceId String provinceId) {
		
		if (StringUtils.isBlank(provinceId)) {
			throw new BusinessException(Constants.ERRORS.VALIDATE_ERROR_CODE,
					"暂无该省地市信息！");
		} else {
			List<String> list = this
					.listBySql("select * from D_CITY where PROVINCE_ID='"
							+ provinceId + "'");
			return list;
		}
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	public List findRegionByCity(@DCity.AnnoCityId String cityId) {
		if (StringUtils.isBlank(cityId)) {
			throw new BusinessException(Constants.ERRORS.VALIDATE_ERROR_CODE,
					"暂无该区域信息！");
		} else {
			List<String> list = this
					.listBySql("select * from D_REGION where CITY_ID='"
							+ cityId + "'");
			return list;
		}
	}
}
